<template>
  <div class="goodsitem" @click="itemClick">
    <img v-lazy='goodsitem.show.img' alt="" @load="imageload"/>
    <div class="goods-info">
      <p>{{ goodsitem.title }}</p>
      <span class="price">{{ goodsitem.price }}</span>
      <span class="collect">{{ goodsitem.cfav }}</span>
      <div class="buy">立即购买</div>
    </div>
  </div>
</template>

<script>
export default {
  name: "goodslistitem",
  props: {
    goodsitem: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  data(){
    return{
      currentIndex:''
    }
  },
  methods:{
    // @load="imageload"监听图片是否加载完成执行函数
    imageload(){
      // this.$bus.$emit总线发射事件
      this.$bus.$emit('itemimageload')
    },
    // 跳转到详情页
    itemClick(){
      // 跳转到路由配置好的详细页
      this.$router.push('/datail/' + this.goodsitem.iid)
    }
  }
};
</script>

<style scoped>
.goodsitem {
  width: 48%;
  padding-bottom: 60px;
  padding-top: 10px;
  position: relative;
}
.goodsitem img {
  width: 100%;
}

.goods-info {
  font-size: 12px;
  position: absolute;
  bottom: 5px;
  left: 0;
  right: 0;
  overflow: hidden;
  text-align: center;
}

.goods-info p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 3px;
}

.goods-info .price {
  color: var(--color-high-text);
  margin-right: 20px;
}

.goods-info .collect {
  position: relative;
}

.goods-info .collect::before {
  content: "";
  position: absolute;
  left: -15px;
  top: 0;
  width: 14px;
  height: 14px;
  background: url("../../../assets/img/common/collect.svg") 0 0/14px 14px;
}
.buy{
  width: 80%;
  line-height: 25px;
  background-color:rgb(255, 87, 119);
  color: white;
  border-radius: 3px;
  margin: 0 auto;
}
.buyclick{
  background-color:white;
  color: rgb(255, 87, 119);
  box-shadow:0 0 1px rgba(255, 87, 119,.5);
}
</style>